/*
 * All content copyright http://www.j2eefast.com, unless
 * otherwise indicated. All rights reserved.
 * No deletion without permission
 */
package com.j2eefast.flowable.bpm.service;

import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ResponseData;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.flowable.bpm.entity.BpmFormDefinitionEntity;
import com.j2eefast.flowable.bpm.entity.BpmProcessDefinitionEntity;
import com.j2eefast.flowable.bpm.entity.BpmTaskFromEntity;
import com.j2eefast.flowable.bpm.mapper.FormDefinitionMapper;
import com.j2eefast.flowable.bpm.mapper.ProcessDefinitionMapper;
import com.j2eefast.framework.utils.Constant;
import org.apache.commons.io.IOUtils;
import org.flowable.engine.HistoryService;
import org.flowable.engine.ManagementService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.form.engine.impl.persistence.entity.FormDefinitionEntity;
import org.flowable.ui.modeler.domain.Model;
import org.flowable.ui.modeler.serviceapi.ModelService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * <p></p>
 *
 * @author: zhouzhou
 * @date: 2020-04-18 23:47
 * @web: http://www.j2eefast.com
 * @version: 1.0.1
 */
@Service
@Transactional(readOnly = true)
public class FormdefService extends ServiceImpl<FormDefinitionMapper, BpmFormDefinitionEntity> {

	@Resource
	protected FormDefinitionMapper formDefinitionMapper;


	/**
	 * 页面展示查询翻页
	 */
	public PageUtil findPage(Map<String, Object> params) {
		String name = (String) params.get("name");
		Page<BpmFormDefinitionEntity> page = formDefinitionMapper.findPage(	new Query<FormDefinitionMapper>(params).getPage(),
				StrUtil.nullToDefault(name,""),
				(String) params.get(Constant.SQL_FILTER));
		return new PageUtil(page);
	}

	public int deleteFormById(Long deploymentId){
		return this.formDefinitionMapper.deleteFormById(deploymentId);
	}

	public BpmFormDefinitionEntity getById(Long deploymentId){
		return this.formDefinitionMapper.getById(deploymentId);
	}

	public BpmFormDefinitionEntity getByUrl(String url){
		return this.formDefinitionMapper.getByUrl(url);
	}

}
